package com.heisen.gateway.controller;

import com.heisnenhub.common.module.enmus.ApiReturnEnums;
import com.heisnenhub.common.module.utils.Api;
import lombok.extern.slf4j.Slf4j;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;
import reactor.core.publisher.Mono;


/**
 * 熔断 回退
 */
@RestController
@Slf4j
public class FallbackController {


    /**
     * \
     * name 是服务名
     *
     * @param name
     * @return
     */
    @RequestMapping("fallback/{name}")
    public Mono<Api> systemFallback(@PathVariable String name) {
        log.info("【熔断 回退】 服務{}", name);
        Api<Object> fail = Api.fail(ApiReturnEnums.SERVICE_DISABLE_AND_TIME_OUT.getCode(), String.format(ApiReturnEnums.SERVICE_DISABLE_AND_TIME_OUT.getDesc(), name));
        return Mono.just(fail);
    }
}


